<?php
/**
 * Created by PhpStorm.
 * User: N
 * Date: 2017/12/13
 * Time: 15:17
 */
namespace common\models;

use Yii;
use yii\base\Model;
use common\models\Models;
use backend\modules\content\models\Sitemodel;
use backend\modules\content\models\Modelfield;
use yii\db\ActiveRecord;
use yii\data\ActiveDataProvider;
use yii\data\Pagination;


/**
 * This is the model class for table "category".
 *
 * @property string $catid
 * @property string $siteid
 **/
class Agenda extends ActiveRecord
{
     /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%agenda}}';
    }



    /**
    * 验证规则
    */
    public function rules()
    {
        return [
            [['title','content','run_time'],'required','message'=>'不能为空'],
            [['title','content','model'],'string','message'=>'格式不正确'],
            [['id','add_time','isadmin','uid','run_time'],'number','message'=>'格式不正确'],
        ];
    }

    public function beforeSave($insert){
        if($insert){
            $this->status=0;
            $this->add_time=time();

            // echo $this->run_time;
            // exit();
            //插入时补充操作
            //$this->inputtime = time();
        }else{
            //修改时补充操作

        }
      
        return true;

    }



        /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'title' => '标题',
            'status' => '状态',
            'content' => '内容',
            'begin_time' => '开始时间',
            'end_time' => '结束时间',
            'run_time'=>'执行时间',
        ];
    }

    public function getUsername()
    {

        $meetingmodel = Meeting::find()->where(['mid' => $this->aid])->one();
        return $meetingmodel->create_username;

    }

    


}